/*
 *  mihf.c
 *  MIHF
 *
 *  Created by injae song on 11. 3. 4..
 *  Copyright 2011 KyungHee Univ. All rights reserved.
 *
 */

#include "mihf.h"


void mihf_init(mihf* mih, char* id )
{
	mih->mih_id = MIHF_ID;
	list_init(&mih->User_table, users_free);
	list_init(&mih->Peer_table, peers_free);
	list_init(&mih->PendingTransaction_table, peers_free);
	list_init(&mih->Event_Service, peers_free);
}

void mih_daemon()
{
	switch (fork()) 
    {
		
        case -1:{
			printf("= ERROR : Can't fork for Daemon                       =\n");
			_exit(0);
		}
		
        case 0:
			break;
		
        default:
			_exit(0);
	}
	
	if (setsid() == -1)
	{
		printf("= ERROR : Can't create new Session                       =\n");
		_exit(0);
	}
	chdir("/");
}

void users_free(void *data)
{
	
}
void peers_free(void *data)
{
	
}